/**
 * 本头文件用来封装socket等相关函数，出现错误返回；
 * @author: sundx
 * @date: 2020-05-29 11:02:22
 * @Last Modified by: sundx
 * @Last Modified time: 2020-05-30 18:21:48
 */
#ifndef __WRAP_H__
#define __WRAP_H__
#define SERVER_PORT 8997
#define LISTEN_WINDOW 20
#define MESSAGE_SIZE 4096

#include <arpa/inet.h>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#include <netinet/in.h>
#include <strings.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <unistd.h>

namespace sdx {

void printError(const char *mes);
int Socket(int domain, int type, int protocol);
int Bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
int Listen(int sockfd, int backlog);
int Accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
int Connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
int serverSocketBindListen();
void setFdUnblock(int fd);
int Epoll_create(int size);
void Epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
int Epoll_wait(int epfd, struct epoll_event *events, int maxevents,
               int timeout);

} // namespace sdx
#endif